$(function () {
    $.ajaxPrefilter(function (option) {
        option.url = 'http://api-breakingnews-web.itheima.net' + option.url
        // 为所有/my/链接设置请求头
        if (option.url.includes('/my/')) {
            option.headers = {
                Authorization: localStorage.getItem('token')
            }
        }
        // 
        option.complete = function (res) {
            if (res.responseJSON.status == 1 && res.responseJSON.message == "身份认证失败！") {
                localStorage.removeItem('token')
                location.href = '/login.html'
            }
        }


    })





})